<?php
     include_once './common.php';
     $cid =  $_GET['cid'];
     $sql = "SELECT * FROM shoppingcart WHERE cid = {$cid}";
     $res = mysqli_query($link,$sql);
     $one = mysqli_fetch_assoc($res);
     if($one['num']>1){
        $num = $one['num']-1;
     }else{
        $num = 1;
     }
     $sql = "UPDATE shoppingcart SET num = '$num' WHERE cid = {$cid}";
     $reslut =  mysqli_query($link,$sql);
     $arr = array();
     if($reslut){
         $arr['info'] = "更新成功";
         $arr['status'] = 1;
     }else{
         $arr['info'] = "更新失败";
         $arr['status'] = 0;
     }
    echo json_encode($arr);
?>